package com.mrdeer.iot.init;

import com.mrdeer.iot.service.DriverCustomService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 项目启动时初始化资源
 * 如:一些初始化操作，提前加载加密证书，初始化线程池等
 */
@Slf4j
@Component
@Configuration
@Order(value = 1)
@ComponentScan(basePackages = {"com.mrdeer.iot"})
public class DriverInitRunner implements ApplicationRunner {

    @Resource
    private DriverCustomService driverCustomService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        // Initialize driver configuration
        driverCustomService.initial();
    }
}
